package com.yunze.apiCommon.upstreamAPI.YunDa;

import com.yunze.apiCommon.upstreamAPI.DianXinCMP5G.SignUtil;
import com.yunze.apiCommon.upstreamAPI.YiYuan.BaseUtile;
import com.yunze.apiCommon.utils.MD5Util;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;

/**
 * 云达 系统 API 接口
 */
public class YunDa_Api {




	//构造赋值
	public YunDa_Api(Map<String, Object> init_map){
		server_Ip  = init_map.get("cd_username").toString();
		appKey  = init_map.get("cd_pwd").toString();
		appSecret  = init_map.get("cd_key").toString();

	}

	// 服务器请求地址
	protected  static String server_Ip = null;
	// 用户登录名称
	public static String appKey  = null;
	// 秘钥key
	public static String appSecret = null;




	public static String getSign(Map<String,Object> map){
		map.put("appSecret",appSecret);
		List<String> list=new ArrayList<>(map.keySet());
		Collections.sort(list);
		StringBuffer sb=new StringBuffer();
		sb.append(appKey);
		for(int i=0;i<list.size();i++){
			String k =list.get(i);
			String v=(String)map.get(k);
			sb.append(k).append(v);
		}
		sb.append(appKey);
		String sign = "";
		System.out.println(sb.toString());
		try {
			sign = MD5Util.MD5Encode(sb.toString() ).toUpperCase();
		}catch (Exception e){
		}
		map.remove("appSecret");
		return sign;
	}

}
